#include "Monster.h"

Monster::Monster() {
	this->initCoord = new Coord3D(0, 0, 0);
	this->coord = new Coord3D(0, 0, 0);
	this->tir = new Coord3D(0, 0, 0);
	this->coordCharger = new Coord3D(0, 0, 0);
	this->monsterBox = new Box();
	this->shootBox = new Box();
	isVisible = true;
	isOnFire = false;
	isCharger = false;
	score = 0;
}

Monster::Monster(float x, float y, float z) {
	this->initCoord = new Coord3D(x, y, z);
	this->coord = new Coord3D(x, y, z);
	this->tir = new Coord3D(x, y, z);
	this->coordCharger = new Coord3D(x, y, z);
	this->monsterBox = new Box();
	this->shootBox = new Box();
	isOnFire = false;
	isVisible = true;
	isCharger = false;
	score = 0;
}

void Monster::move(float dx, float dy, float dz) {
	if (!isCharger) {
		this->monsterBox->move(dx, dy, dz);
	}
	//this->shootBox->move(dx, dy, dz);
	this->coord->move(dx, dy, dz);
	//if (!isOnFire)
	//	this->tir->move(dx, dy, dz);
}

void Monster::moveCharger(float dx, float dy, float dz) {
	this->monsterBox->move(dx, dy, dz);
	this->coordCharger->move(dx, dy, dz);
}

void Monster::explode() {
	for (int x = monsterBox->x + 0.5F; x < monsterBox->x + monsterBox->w; x += 2) {
		for (int y = monsterBox->y + 0.5F; y < monsterBox->y + monsterBox->h; y++) {
			if (((int) x) % 2 == 0 && ((int) y) % 2 == 0 || ((int) x) % 2 != 0 && ((int) y) % 2 != 0) {
				glPushMatrix();
				glTranslatef(x, y, 0.0F);
				Figure::drawCuboid(1.0, 1.0, 1.0);
				glPopMatrix();
			}
		}
	}
}

bool Monster::isShot(Box* shoot) {
	if (this->monsterBox->collision(shoot)) {
		return true;
	} 
	return false;
}
 
Monster::~Monster(){
	delete this->coord;
	delete this->monsterBox;
}
